#define MODULE

/** @file
 * Example module, shwos basic init, destruct and callback handleing.
 */
#include <stdio.h>
#include "../core/include/plugin.h"

/** Modpack pointer. */
modpack_t *mpp;

/**
 * Handle a callback response. 
 * @param data Data from the application.
 * @return 0 on ok.
 */
int callback(char *data) {
	mpp->event(0, "%s", data);
	return 0;
}

/**
 * Module destructor, called when unloading occours.
 */
void destruct() {
	mpp->event(0, "mod.o: destructing");
}

/**
 * Module init function.
 * @param modpack Modpack sent by app.
 * @return 0 on success, 1 on fail.
 */
int mod_init(modpack_t *modpack) {
	modpack->event(0, "mod.o: hello world");
	modpack->callback = callback;
	modpack->destruct = destruct;
	mpp = modpack;
	
	mpp->callme(callback);
	return 0;
}
